home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.396 < prev    next >
Text File  |  1992-02-06  |  1KB  |  42 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;}
  2. \paperw12740
  3. \paperh8500
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 Appkit Text Adding At End\
  8.     \
  9. Q:  How can you add text to the end of a text object?\
  10.  
  11. \i     \
  12.  
  13. \i0 A: 
  14. \fc0  The trick is to make a zero length selection at the end of the text, and add the new text there.  The following code snippet illustrates the necessary steps:\
  15. \
  16.  
  17. \f1\fs24 /* This routine assumes that you have defined currentDocWindow somewhere else */ \
  18. \
  19. \
  20.  
  21. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 - addText:(const char *)newString\
  22. \{\
  23.     int length;\
  24.     id  currentDocText;\
  25.     \
  26.     /* Get the current text document */\
  27.     currentDocText = [[currentDocWindow contentView]docView];\
  28.     length = [currentDocText textLength];\
  29.     [currentDocText setSel:length :length];\
  30.     [currentDocText replaceSel:newString];\
  31.     \
  32.     return self;\
  33. \}\
  34.  
  35. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28\fc0 \
  36. QA396\
  37. \
  38. Valid for 1.0\
  39. Valid for 2.0\
  40. \
  41.  
  42.